package com.chengqs.rainbow.im.gateway.server.command;

import com.chengqs.rainbow.common.core.exception.SystemException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <B>主类名称：</B>ServerCommandHandlerFactory<BR>
 * <B>概要说明：</B>enter<BR>
 *
 * @author: chengqs
 * @create: 2025-09-13 16:29:25
 **/
@Component
@RequiredArgsConstructor
public class ServerCommandHandlerFactory {

    private final List<ServerCommandHandler> commandHandlers;

    public ServerCommandHandler getCommandHandler(int type) {
        for (ServerCommandHandler commandHandler : commandHandlers) {
            if (type == commandHandler.getType()) {
                return commandHandler;
            }
        }
        throw new SystemException("找不到命令处理器");
    }
}
